// proxy/AgriculturalMachineProxy.java
package proxy;

import model.AgriculturalMachine;

public class AgriculturalMachineProxy implements AgriculturalMachine {
    private AgriculturalMachine machine;
    private boolean isAuthorized;

    public AgriculturalMachineProxy(AgriculturalMachine machine, boolean isAuthorized) {
        this.machine = machine;
        this.isAuthorized = isAuthorized;
    }

    @Override
    public void start() {
        if (isAuthorized) {
            machine.start();
        } else {
            System.out.println("未授权，无法启动设备");
        }
    }

    @Override
    public void stop() {
        if (isAuthorized) {
            machine.stop();
        } else {
            System.out.println("未授权，无法停止设备");
        }
    }

    @Override
    public void setPathPlanningStrategy(strategy.PathPlanningStrategy strategy) {
        if (isAuthorized) {
            machine.setPathPlanningStrategy(strategy);
        } else {
            System.out.println("未授权，无法设置路径规划策略");
        }
    }

    @Override
    public String planPath() {
        if (isAuthorized) {
            return machine.planPath();
        } else {
            System.out.println("未授权，无法获取路径规划");
            return null;
        }
    }

    @Override
    public String getStatus() {
        if (isAuthorized) {
            return machine.getStatus();
        } else {
            System.out.println("未授权，无法获取设备状态");
            return null;
        }
    }

    @Override
    public String getLocation() {
        if (isAuthorized) {
            return machine.getLocation();
        } else {
            System.out.println("未授权，无法获取设备位置");
            return null;
        }
    }

    @Override
    public double getFuel() {
        if (isAuthorized) {
            return machine.getFuel();
        } else {
            System.out.println("未授权，无法获取设备油量");
            return 0;
        }
    }
}